package com.wanglixia.pc;

import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

/**
 * 功能描述:
 * <p>
 * Created by Mr.wang on 2017/9/17 11:57.
 */
public class AuthUtil {

//    public static final String APPID = "wx6da0276321aa75ae";
//    public static final String APPSECRET = "90928ba90bdedc212970a584db0c2a7d";
    public static final String APPID = "wx77d58cbc469755df";
    public static final String APPSECRET = "ddee3fb3d53e7b1d3bb99db965c442e4";

    public static JSONObject doGetJson(String url) throws IOException {
        JSONObject jsonObject = null;
        DefaultHttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        HttpResponse httpResponse = client.execute(httpGet);
        HttpEntity entity = httpResponse.getEntity();
        if (entity != null) {
            String result = EntityUtils.toString(entity, "UTF-8");
            jsonObject = JSONObject.fromObject(result);
        }
        httpGet.releaseConnection();
        return jsonObject;
    }
}
